﻿using System;
using System.Diagnostics;
using WindowsAPI.Processes;
using WindowsAPI.Windows;

namespace Test_Console
{
    class Program
    {
        static void Main(string[] args)
        {
            //Parce(args);


            var calc = Window.GetWindow("Калькулятор");

            calc.SetForeground();

            //calc.ToString();

            //calc.Width += 20;


            //var file = new FileInfo(@"c:\123.txt");
            //Console.WriteLine("File:{0}", file);
            //Console.WriteLine("Length:{0}b", file.Length);

            //file.GetDataStreamsNames().Foreach(Console.WriteLine);

            //Console.ReadLine();
        }

        /*
                private static void Parce(string[] args)
                {
                    if(args == null || args.Length == 0)
                        args = new[] { "GetProcesses" };

                    var command = args[0].ToLower();

                    switch(command)
                    {
                        default:
                            Console.WriteLine("Неизвестная команда {0}", command);
                            break;

                        case "getprocesses":
                            Process.GetProcesses().Foreach(PrintProcess);
                            break;

                        case "pid":
                            if(args.Length < 2)
                            {
                                Console.WriteLine("Не указан идентификатор процесса");
                                break;
                            }
                            var pid_string = args[1];
                            int pid;
                            try
                            {
                                pid = int.Parse(pid_string);
                            }
                            catch(FormatException error)
                            {
                                Console.WriteLine(error);
                                break;
                            }

                            var process = Process.GetProcessById(pid);

                            //process.GetPrivilages();


                            break;
                    }
                }
        */

        private static void PrintProcess(Process process)
        {
            Console.WriteLine("/* ----------------------------------------------------------------------- */");
            Console.Write("{0}:", process.Id);
            try
            {
                Console.WriteLine(process.ProcessName);
            }
            catch(Exception Error)
            {
                Console.WriteLine("\r\n{0}", Error);
            }
            try
            {
                Console.WriteLine(process.GetProcessFileInfo());
            }
            catch(Exception Error)
            {
                Console.WriteLine("\r\n{0}", Error);
            }

            Console.WriteLine();
        }

        /*
                [STAThread]
                private static void StartForm()
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new MainForm());
                }
        */

    }
}
